﻿/*******************************************************************************
 * AAEngine
 * Copyright (c) 2010 Mike Jarosch
 *
 * Original source PushButton Engine:
 * Copyright (C) 2009 PushButton Labs, LLC
 * For more information see http://www.pushbuttonengine.com
 *
 * This file is licensed under the terms of the MIT license, which is included
 * in the "MIT License.txt" file at the root directory of this SDK.
 ******************************************************************************/

using System.Collections.Generic;
using Microsoft.Xna.Framework.Input;

namespace AAEngine.Engine
{
    public class InputKey
    {
        private static Dictionary<int, InputKey> _codeMap = new Dictionary<int, InputKey>();
        private static Dictionary<Keys, InputKey> _keyMap = new Dictionary<Keys, InputKey>();
        private static Dictionary<Buttons, InputKey> _buttonMap = new Dictionary<Buttons, InputKey>();
        private static Dictionary<string, InputKey> _nameMap;

        public static readonly InputKey INVALID = new InputKey(-1);

        public static readonly InputKey A = new InputKey(Keys.A);
        public static readonly InputKey ADD = new InputKey(Keys.Add);
        public static readonly InputKey APPS = new InputKey(Keys.Apps);
        public static readonly InputKey ATTN = new InputKey(Keys.Attn);
        public static readonly InputKey B = new InputKey(Keys.B);
        public static readonly InputKey BACKSPACE = new InputKey(Keys.Back);
        public static readonly InputKey BROWSER_BACK = new InputKey(Keys.BrowserBack);
        public static readonly InputKey BROWSER_FAVORITES = new InputKey(Keys.BrowserFavorites);
        public static readonly InputKey BROWSER_FORWARD = new InputKey(Keys.BrowserForward);
        public static readonly InputKey BROWSER_HOME = new InputKey(Keys.BrowserHome);
        public static readonly InputKey BROWSER_REFRESH = new InputKey(Keys.BrowserRefresh);
        public static readonly InputKey BROWSER_SEARCH = new InputKey(Keys.BrowserSearch);
        public static readonly InputKey BROWSER_STOP = new InputKey(Keys.BrowserStop);
        public static readonly InputKey C = new InputKey(Keys.C);
        public static readonly InputKey CAPSLOCK = new InputKey(Keys.CapsLock);
        public static readonly InputKey CHATPAD_GREEN = new InputKey(Keys.ChatPadGreen);
        public static readonly InputKey CHATPAD_ORANGE = new InputKey(Keys.ChatPadOrange);
        public static readonly InputKey CRSEL = new InputKey(Keys.Crsel);
        public static readonly InputKey D = new InputKey(Keys.D);
        public static readonly InputKey DIGIT_0 = new InputKey(Keys.D0);
        public static readonly InputKey DIGIT_1 = new InputKey(Keys.D1);
        public static readonly InputKey DIGIT_2 = new InputKey(Keys.D2);
        public static readonly InputKey DIGIT_3 = new InputKey(Keys.D3);
        public static readonly InputKey DIGIT_4 = new InputKey(Keys.D4);
        public static readonly InputKey DIGIT_5 = new InputKey(Keys.D5);
        public static readonly InputKey DIGIT_6 = new InputKey(Keys.D6);
        public static readonly InputKey DIGIT_7 = new InputKey(Keys.D7);
        public static readonly InputKey DIGIT_8 = new InputKey(Keys.D8);
        public static readonly InputKey DIGIT_9 = new InputKey(Keys.D9);
        public static readonly InputKey DECIMAL = new InputKey(Keys.Decimal);
        public static readonly InputKey DELETE = new InputKey(Keys.Delete);
        public static readonly InputKey DIVIDE = new InputKey(Keys.Divide);
        public static readonly InputKey DOWN = new InputKey(Keys.Down);
        public static readonly InputKey E = new InputKey(Keys.E);
        public static readonly InputKey END = new InputKey(Keys.End);
        public static readonly InputKey ENTER = new InputKey(Keys.Enter);
        public static readonly InputKey ERASE_EOF = new InputKey(Keys.EraseEof);
        public static readonly InputKey ESCAPE = new InputKey(Keys.Escape);
        public static readonly InputKey EXECUTE = new InputKey(Keys.Execute);
        public static readonly InputKey EXSEL = new InputKey(Keys.Exsel);
        public static readonly InputKey F = new InputKey(Keys.F);
        public static readonly InputKey F1 = new InputKey(Keys.F1);
        public static readonly InputKey F10 = new InputKey(Keys.F10);
        public static readonly InputKey F11 = new InputKey(Keys.F11);
        public static readonly InputKey F12 = new InputKey(Keys.F12);
        public static readonly InputKey F13 = new InputKey(Keys.F13);
        public static readonly InputKey F14 = new InputKey(Keys.F14);
        public static readonly InputKey F15 = new InputKey(Keys.F15);
        public static readonly InputKey F16 = new InputKey(Keys.F16);
        public static readonly InputKey F17 = new InputKey(Keys.F17);
        public static readonly InputKey F18 = new InputKey(Keys.F18);
        public static readonly InputKey F19 = new InputKey(Keys.F19);
        public static readonly InputKey F2 = new InputKey(Keys.F2);
        public static readonly InputKey F20 = new InputKey(Keys.F20);
        public static readonly InputKey F21 = new InputKey(Keys.F21);
        public static readonly InputKey F22 = new InputKey(Keys.F22);
        public static readonly InputKey F23 = new InputKey(Keys.F23);
        public static readonly InputKey F24 = new InputKey(Keys.F24);
        public static readonly InputKey F3 = new InputKey(Keys.F3);
        public static readonly InputKey F4 = new InputKey(Keys.F4);
        public static readonly InputKey F5 = new InputKey(Keys.F5);
        public static readonly InputKey F6 = new InputKey(Keys.F6);
        public static readonly InputKey F7 = new InputKey(Keys.F7);
        public static readonly InputKey F8 = new InputKey(Keys.F8);
        public static readonly InputKey F9 = new InputKey(Keys.F9);
        public static readonly InputKey G = new InputKey(Keys.G);
        public static readonly InputKey H = new InputKey(Keys.H);
        public static readonly InputKey HELP = new InputKey(Keys.Help);
        public static readonly InputKey HOME = new InputKey(Keys.Home);
        public static readonly InputKey I = new InputKey(Keys.I);
        public static readonly InputKey IME_CONVERT = new InputKey(Keys.ImeConvert);
        public static readonly InputKey IME_NO_CONVERT = new InputKey(Keys.ImeNoConvert);
        public static readonly InputKey INSERT = new InputKey(Keys.Insert);
        public static readonly InputKey J = new InputKey(Keys.J);
        public static readonly InputKey K = new InputKey(Keys.K);
        public static readonly InputKey KANA = new InputKey(Keys.Kana);
        public static readonly InputKey KANJI = new InputKey(Keys.Kanji);
        public static readonly InputKey L = new InputKey(Keys.L);
        public static readonly InputKey LAUNCH_APPLICATION1 = new InputKey(Keys.LaunchApplication1);
        public static readonly InputKey LAUNCH_APPLICATION2 = new InputKey(Keys.LaunchApplication2);
        public static readonly InputKey LAUNCH_MAIL = new InputKey(Keys.LaunchMail);
        public static readonly InputKey LEFT = new InputKey(Keys.Left);
        public static readonly InputKey LEFT_ALT = new InputKey(Keys.LeftAlt);
        public static readonly InputKey LEFT_CONTROL = new InputKey(Keys.LeftControl);
        public static readonly InputKey LEFT_SHIFT = new InputKey(Keys.LeftShift);
        public static readonly InputKey LEFT_COMMAND = new InputKey(Keys.LeftWindows);
        public static readonly InputKey M = new InputKey(Keys.M);
        public static readonly InputKey MEDIA_NEXT_TRACK = new InputKey(Keys.MediaNextTrack);
        public static readonly InputKey MEDIA_PLAY_PAUSE = new InputKey(Keys.MediaPlayPause);
        public static readonly InputKey MEDIA_PREVIOUS_TRACK = new InputKey(Keys.MediaPreviousTrack);
        public static readonly InputKey MEDIA_STOP = new InputKey(Keys.MediaStop);
        public static readonly InputKey MULTIPLY = new InputKey(Keys.Multiply);
        public static readonly InputKey N = new InputKey(Keys.N);
        public static readonly InputKey NONE = new InputKey(Keys.None);
        public static readonly InputKey NUMLOCK = new InputKey(Keys.NumLock);
        public static readonly InputKey NUMPAD_0 = new InputKey(Keys.NumPad0);
        public static readonly InputKey NUMPAD_1 = new InputKey(Keys.NumPad1);
        public static readonly InputKey NUMPAD_2 = new InputKey(Keys.NumPad2);
        public static readonly InputKey NUMPAD_3 = new InputKey(Keys.NumPad3);
        public static readonly InputKey NUMPAD_4 = new InputKey(Keys.NumPad4);
        public static readonly InputKey NUMPAD_5 = new InputKey(Keys.NumPad5);
        public static readonly InputKey NUMPAD_6 = new InputKey(Keys.NumPad6);
        public static readonly InputKey NUMPAD_7 = new InputKey(Keys.NumPad7);
        public static readonly InputKey NUMPAD_8 = new InputKey(Keys.NumPad8);
        public static readonly InputKey NUMPAD_9 = new InputKey(Keys.NumPad9);
        public static readonly InputKey O = new InputKey(Keys.O);
        public static readonly InputKey OEM_8 = new InputKey(Keys.Oem8);
        public static readonly InputKey OEM_AUTO = new InputKey(Keys.OemAuto);
        public static readonly InputKey OEM_BLACKSLASH = new InputKey(Keys.OemBackslash);
        public static readonly InputKey OEM_CLEAR = new InputKey(Keys.OemClear);
        public static readonly InputKey OEM_CLOSEBRACKETS = new InputKey(Keys.OemCloseBrackets);
        public static readonly InputKey OEM_COMMA = new InputKey(Keys.OemComma);
        public static readonly InputKey OEM_COPY = new InputKey(Keys.OemCopy);
        public static readonly InputKey OEM_ENLW = new InputKey(Keys.OemEnlW);
        public static readonly InputKey OEM_MINUS = new InputKey(Keys.OemMinus);
        public static readonly InputKey OEM_OPENBRACKETS = new InputKey(Keys.OemOpenBrackets);
        public static readonly InputKey OEM_PERIOD = new InputKey(Keys.OemPeriod);
        public static readonly InputKey OEM_PIPE = new InputKey(Keys.OemPipe);
        public static readonly InputKey OEM_PLUS = new InputKey(Keys.OemPlus);
        public static readonly InputKey OEM_QUESTION = new InputKey(Keys.OemQuestion);
        public static readonly InputKey OEM_QUOTES = new InputKey(Keys.OemQuotes);
        public static readonly InputKey OEM_SEMICOLON = new InputKey(Keys.OemSemicolon);
        public static readonly InputKey OEM_TILDE = new InputKey(Keys.OemTilde);
        public static readonly InputKey P = new InputKey(Keys.P);
        public static readonly InputKey PA1 = new InputKey(Keys.Pa1);
        public static readonly InputKey PAGEDOWN = new InputKey(Keys.PageDown);
        public static readonly InputKey PAGEUP = new InputKey(Keys.PageUp);
        public static readonly InputKey PAUSE = new InputKey(Keys.Pause);
        public static readonly InputKey PLAY = new InputKey(Keys.Play);
        public static readonly InputKey PRINT = new InputKey(Keys.Print);
        public static readonly InputKey PRINTSCREEN = new InputKey(Keys.PrintScreen);
        public static readonly InputKey PROCESSKEY = new InputKey(Keys.ProcessKey);
        public static readonly InputKey Q = new InputKey(Keys.Q);
        public static readonly InputKey R = new InputKey(Keys.R);
        public static readonly InputKey RIGHT = new InputKey(Keys.Right);
        public static readonly InputKey RIGHT_ALT = new InputKey(Keys.RightAlt);
        public static readonly InputKey RIGHT_CONTROL = new InputKey(Keys.RightControl);
        public static readonly InputKey RIGHT_SHIFT = new InputKey(Keys.RightShift);
        public static readonly InputKey RIGHT_COMMAND = new InputKey(Keys.RightWindows);
        public static readonly InputKey S = new InputKey(Keys.S);
        public static readonly InputKey SCROLL = new InputKey(Keys.Scroll);
        public static readonly InputKey SELECT = new InputKey(Keys.Select);
        public static readonly InputKey SELECT_MEDIA = new InputKey(Keys.SelectMedia);
        public static readonly InputKey SEPARATOR = new InputKey(Keys.Separator);
        public static readonly InputKey SLEEP = new InputKey(Keys.Sleep);
        public static readonly InputKey SPACE = new InputKey(Keys.Space);
        public static readonly InputKey SUBTRACT = new InputKey(Keys.Subtract);
        public static readonly InputKey T = new InputKey(Keys.T);
        public static readonly InputKey TAB = new InputKey(Keys.Tab);
        public static readonly InputKey U = new InputKey(Keys.U);
        public static readonly InputKey UP = new InputKey(Keys.Up);
        public static readonly InputKey V = new InputKey(Keys.V);
        public static readonly InputKey VOLUME_DOWN = new InputKey(Keys.VolumeDown);
        public static readonly InputKey VOLUME_MUTE = new InputKey(Keys.VolumeMute);
        public static readonly InputKey VOLUME_UP = new InputKey(Keys.VolumeUp);
        public static readonly InputKey W = new InputKey(Keys.W);
        public static readonly InputKey X = new InputKey(Keys.X);
        public static readonly InputKey Y = new InputKey(Keys.Y);
        public static readonly InputKey Z = new InputKey(Keys.Z);
        public static readonly InputKey ZOOM = new InputKey(Keys.Zoom);

        public static readonly InputKey BUTTON_A = new InputKey(Buttons.A);
        public static readonly InputKey BUTTON_B = new InputKey(Buttons.B);
        public static readonly InputKey BUTTON_BACK = new InputKey(Buttons.Back);
        public static readonly InputKey BUTTON_BIG = new InputKey(Buttons.BigButton);
        public static readonly InputKey BUTTON_DPAD_DOWN = new InputKey(Buttons.DPadDown);
        public static readonly InputKey BUTTON_DPAD_LEFT = new InputKey(Buttons.DPadLeft);
        public static readonly InputKey BUTTON_DPAD_RIGHT = new InputKey(Buttons.DPadRight);
        public static readonly InputKey BUTTON_DPAD_UP = new InputKey(Buttons.DPadUp);
        public static readonly InputKey BUTTON_LEFT_SHOULDER = new InputKey(Buttons.LeftShoulder);
        public static readonly InputKey BUTTON_LEFT_STICK = new InputKey(Buttons.LeftStick);
        public static readonly InputKey BUTTON_LEFT_THUMB_DOWN = new InputKey(Buttons.LeftThumbstickDown);
        public static readonly InputKey BUTTON_LEFT_THUMB_LEFT = new InputKey(Buttons.LeftThumbstickLeft);
        public static readonly InputKey BUTTON_LEFT_THUMB_RIGHT = new InputKey(Buttons.LeftThumbstickRight);
        public static readonly InputKey BUTTON_LEFT_THUMB_UP = new InputKey(Buttons.LeftThumbstickUp);
        public static readonly InputKey BUTTON_LEFT_TRIGGER = new InputKey(Buttons.LeftTrigger);
        public static readonly InputKey BUTTON_RIGHT_SHOULDER = new InputKey(Buttons.RightShoulder);
        public static readonly InputKey BUTTON_RIGHT_STICK = new InputKey(Buttons.RightStick);
        public static readonly InputKey BUTTON_RIGHT_THUMB_DOWN = new InputKey(Buttons.RightThumbstickDown);
        public static readonly InputKey BUTTON_RIGHT_THUMB_LEFT = new InputKey(Buttons.RightThumbstickLeft);
        public static readonly InputKey BUTTON_RIGHT_THUMB_RIGHT = new InputKey(Buttons.RightThumbstickRight);
        public static readonly InputKey BUTTON_RIGHT_THUMB_UP = new InputKey(Buttons.RightThumbstickUp);
        public static readonly InputKey BUTTON_RIGHT_TRIGGER = new InputKey(Buttons.RightTrigger);
        public static readonly InputKey BUTTON_START = new InputKey(Buttons.Start);
        public static readonly InputKey BUTTON_X = new InputKey(Buttons.X);
        public static readonly InputKey BUTTON_Y = new InputKey(Buttons.Y);

        public static readonly InputKey MOUSE_BUTTON1 = new InputKey(0);
        public static readonly InputKey MOUSE_BUTTON2 = new InputKey(1);
        public static readonly InputKey MOUSE_BUTTON3 = new InputKey(2);
        public static readonly InputKey MOUSE_BUTTON4 = new InputKey(3);
        public static readonly InputKey MOUSE_BUTTON5 = new InputKey(4);
        public static readonly InputKey MOUSE_X = new InputKey(5);
        public static readonly InputKey MOUSE_X_DELTA = new InputKey(6);
        public static readonly InputKey MOUSE_Y = new InputKey(7);
        public static readonly InputKey MOUSE_Y_DELTA = new InputKey(8);
        public static readonly InputKey MOUSE_WHEEL = new InputKey(9);
        public static readonly InputKey MOUSE_WHEEL_DELTA = new InputKey(10);

        public static readonly InputKey THUMBSTICK_LEFT_X = new InputKey(100);
        public static readonly InputKey THUMBSTICK_LEFT_X_DELTA = new InputKey(101);
        public static readonly InputKey THUMBSTICK_LEFT_Y = new InputKey(102);
        public static readonly InputKey THUMBSTICK_LEFT_Y_DELTA = new InputKey(103);
        public static readonly InputKey THUMBSTICK_RIGHT_X = new InputKey(104);
        public static readonly InputKey THUMBSTICK_RIGHT_X_DELTA = new InputKey(105);
        public static readonly InputKey THUMBSTICK_RIGHT_Y = new InputKey(106);
        public static readonly InputKey THUMBSTICK_RIGHT_Y_DELTA = new InputKey(107);

        public static readonly InputKey TRIGGER_LEFT = new InputKey(200);
        public static readonly InputKey TRIGGER_LEFT_DELTA = new InputKey(201);
        public static readonly InputKey TRIGGER_RIGHT = new InputKey(202);
        public static readonly InputKey TRIGGER_RIGHT_DELTA = new InputKey(203);

        private int? _code = null;
        private Keys? _key = null;
        private Buttons? _button = null;

        private InputKey(int code)
        {
            _code = code;
            _codeMap[code] = this;
        }

        private InputKey(Keys key)
        {
            _key = key;
            _keyMap[key] = this;
        }

        private InputKey (Buttons button)
        {
            _button = button;
            _buttonMap[button] = this;
        }

        public static InputKey InputKeyForKeys(Keys key)
        {
            if (_keyMap.ContainsKey(key))
            {
                return _keyMap[key];
            }

            return INVALID;
        }

        public static InputKey InputKeyForButtons(Buttons button)
        {
            if (_buttonMap.ContainsKey(button))
            {
                return _buttonMap[button];
            }

            return INVALID;
        }

        public static InputKey InputKeyForCode(int code)
        {
            if (_codeMap.ContainsKey(code))
            {
                return _codeMap[code];
            }

            return INVALID;
        }

        public static InputKey InputKeyForName(string name)
        {
            if (_nameMap == null)
            {
                SetupNameMap();
            }

            if (_nameMap.ContainsKey(name))
            {
                return _nameMap[name];
            }

            return InputKey.INVALID;
        }

        public static string NameForInputKey(InputKey key)
        {
            if (_nameMap == null)
            {
                SetupNameMap();
            }

            if (_nameMap.ContainsValue(key))
            {
                foreach (string k in _nameMap.Keys)
                {
                    if (_nameMap[k] == key)
                    {
                        return k;
                    }
                }
            }

            return null;
        }

        private static void SetupNameMap()
        {
            _nameMap = new Dictionary<string, InputKey>();

            _nameMap["A"] = A;
            _nameMap["ADD"] = ADD;
            _nameMap["APPS"] = APPS;
            _nameMap["ATTN"] = ATTN;
            _nameMap["B"] = B;
            _nameMap["BACKSPACE"] = BACKSPACE;
            _nameMap["BROWSER_BACK"] = BROWSER_BACK;
            _nameMap["BROWSER_FAVORITES"] = BROWSER_FAVORITES;
            _nameMap["BROWSER_FORWARD"] = BROWSER_FORWARD;
            _nameMap["BROWSER_HOME"] = BROWSER_HOME;
            _nameMap["BROWSER_REFRESH"] = BROWSER_REFRESH;
            _nameMap["BROWSER_SEARCH"] = BROWSER_SEARCH;
            _nameMap["BROWSER_STOP"] = BROWSER_STOP;
            _nameMap["C"] = C;
            _nameMap["CAPSLOCK"] = CAPSLOCK;
            _nameMap["CHATPAD_GREEN"] = CHATPAD_GREEN;
            _nameMap["CHATPAD_ORANGE"] = CHATPAD_ORANGE;
            _nameMap["CRSEL"] = CRSEL;
            _nameMap["D"] = D;
            _nameMap["DIGIT_0"] = DIGIT_0;
            _nameMap["DIGIT_1"] = DIGIT_1;
            _nameMap["DIGIT_2"] = DIGIT_2;
            _nameMap["DIGIT_3"] = DIGIT_3;
            _nameMap["DIGIT_4"] = DIGIT_4;
            _nameMap["DIGIT_5"] = DIGIT_5;
            _nameMap["DIGIT_6"] = DIGIT_6;
            _nameMap["DIGIT_7"] = DIGIT_7;
            _nameMap["DIGIT_8"] = DIGIT_8;
            _nameMap["DIGIT_9"] = DIGIT_9;
            _nameMap["DECIMAL"] = DECIMAL;
            _nameMap["DELETE"] = DELETE;
            _nameMap["DIVIDE"] = DIVIDE;
            _nameMap["DOWN"] = DOWN;
            _nameMap["E"] = E;
            _nameMap["END"] = END;
            _nameMap["ENTER"] = ENTER;
            _nameMap["ERASE_EOF"] = ERASE_EOF;
            _nameMap["ESCAPE"] = ESCAPE;
            _nameMap["EXECUTE"] = EXECUTE;
            _nameMap["EXSEL"] = EXSEL;
            _nameMap["F"] = F;
            _nameMap["F1"] = F1;
            _nameMap["F10"] = F10;
            _nameMap["F11"] = F11;
            _nameMap["F12"] = F12;
            _nameMap["F13"] = F13;
            _nameMap["F14"] = F14;
            _nameMap["F15"] = F15;
            _nameMap["F16"] = F16;
            _nameMap["F17"] = F17;
            _nameMap["F18"] = F18;
            _nameMap["F19"] = F19;
            _nameMap["F2"] = F2;
            _nameMap["F20"] = F20;
            _nameMap["F21"] = F21;
            _nameMap["F22"] = F22;
            _nameMap["F23"] = F23;
            _nameMap["F24"] = F24;
            _nameMap["F3"] = F3;
            _nameMap["F4"] = F4;
            _nameMap["F5"] = F5;
            _nameMap["F6"] = F6;
            _nameMap["F7"] = F7;
            _nameMap["F8"] = F8;
            _nameMap["F9"] = F9;
            _nameMap["G"] = G;
            _nameMap["H"] = H;
            _nameMap["HELP"] = HELP;
            _nameMap["HOME"] = HOME;
            _nameMap["I"] = I;
            _nameMap["IME_CONVERT"] = IME_CONVERT;
            _nameMap["IME_NO_CONVERT"] = IME_NO_CONVERT;
            _nameMap["INSERT"] = INSERT;
            _nameMap["J"] = J;
            _nameMap["K"] = K;
            _nameMap["KANA"] = KANA;
            _nameMap["KANJI"] = KANJI;
            _nameMap["L"] = L;
            _nameMap["LAUNCH_APPLICATION1"] = LAUNCH_APPLICATION1;
            _nameMap["LAUNCH_APPLICATION2"] = LAUNCH_APPLICATION2;
            _nameMap["LAUNCH_MAIL"] = LAUNCH_MAIL;
            _nameMap["LEFT"] = LEFT;
            _nameMap["LEFT_ALT"] = LEFT_ALT;
            _nameMap["LEFT_CONTROL"] = LEFT_CONTROL;
            _nameMap["LEFT_SHIFT"] = LEFT_SHIFT;
            _nameMap["LEFT_COMMAND"] = LEFT_COMMAND;
            _nameMap["M"] = M;
            _nameMap["MEDIA_NEXT_TRACK"] = MEDIA_NEXT_TRACK;
            _nameMap["MEDIA_PLAY_PAUSE"] = MEDIA_PLAY_PAUSE;
            _nameMap["MEDIA_PREVIOUS_TRACK"] = MEDIA_PREVIOUS_TRACK;
            _nameMap["MEDIA_STOP"] = MEDIA_STOP;
            _nameMap["MULTIPLY"] = MULTIPLY;
            _nameMap["N"] = N;
            _nameMap["NONE"] = NONE;
            _nameMap["NUMLOCK"] = NUMLOCK;
            _nameMap["NUMPAD_0"] = NUMPAD_0;
            _nameMap["NUMPAD_1"] = NUMPAD_1;
            _nameMap["NUMPAD_2"] = NUMPAD_2;
            _nameMap["NUMPAD_3"] = NUMPAD_3;
            _nameMap["NUMPAD_4"] = NUMPAD_4;
            _nameMap["NUMPAD_5"] = NUMPAD_5;
            _nameMap["NUMPAD_6"] = NUMPAD_6;
            _nameMap["NUMPAD_7"] = NUMPAD_7;
            _nameMap["NUMPAD_8"] = NUMPAD_8;
            _nameMap["NUMPAD_9"] = NUMPAD_9;
            _nameMap["O"] = O;
            _nameMap["OEM_8"] = OEM_8;
            _nameMap["OEM_AUTO"] = OEM_AUTO;
            _nameMap["OEM_BLACKSLASH"] = OEM_BLACKSLASH;
            _nameMap["OEM_CLEAR"] = OEM_CLEAR;
            _nameMap["OEM_CLOSEBRACKETS"] = OEM_CLOSEBRACKETS;
            _nameMap["OEM_COMMA"] = OEM_COMMA;
            _nameMap["OEM_COPY"] = OEM_COPY;
            _nameMap["OEM_ENLW"] = OEM_ENLW;
            _nameMap["OEM_MINUS"] = OEM_MINUS;
            _nameMap["OEM_OPENBRACKETS"] = OEM_OPENBRACKETS;
            _nameMap["OEM_PERIOD"] = OEM_PERIOD;
            _nameMap["OEM_PIPE"] = OEM_PIPE;
            _nameMap["OEM_PLUS"] = OEM_PLUS;
            _nameMap["OEM_QUESTION"] = OEM_QUESTION;
            _nameMap["OEM_QUOTES"] = OEM_QUOTES;
            _nameMap["OEM_SEMICOLON"] = OEM_SEMICOLON;
            _nameMap["OEM_TILDE"] = OEM_TILDE;
            _nameMap["P"] = P;
            _nameMap["PA1"] = PA1;
            _nameMap["PAGEDOWN"] = PAGEDOWN;
            _nameMap["PAGEUP"] = PAGEUP;
            _nameMap["PAUSE"] = PAUSE;
            _nameMap["PLAY"] = PLAY;
            _nameMap["PRINT"] = PRINT;
            _nameMap["PRINTSCREEN"] = PRINTSCREEN;
            _nameMap["PROCESSKEY"] = PROCESSKEY;
            _nameMap["Q"] = Q;
            _nameMap["R"] = R;
            _nameMap["RIGHT"] = RIGHT;
            _nameMap["RIGHT_ALT"] = RIGHT_ALT;
            _nameMap["RIGHT_CONTROL"] = RIGHT_CONTROL;
            _nameMap["RIGHT_SHIFT"] = RIGHT_SHIFT;
            _nameMap["RIGHT_COMMAND"] = RIGHT_COMMAND;
            _nameMap["S"] = S;
            _nameMap["SCROLL"] = SCROLL;
            _nameMap["SELECT"] = SELECT;
            _nameMap["SELECT_MEDIA"] = SELECT_MEDIA;
            _nameMap["SEPARATOR"] = SEPARATOR;
            _nameMap["SLEEP"] = SLEEP;
            _nameMap["SPACE"] = SPACE;
            _nameMap["SUBTRACT"] = SUBTRACT;
            _nameMap["T"] = T;
            _nameMap["TAB"] = TAB;
            _nameMap["U"] = U;
            _nameMap["UP"] = UP;
            _nameMap["V"] = V;
            _nameMap["VOLUME_DOWN"] = VOLUME_DOWN;
            _nameMap["VOLUME_MUTE"] = VOLUME_MUTE;
            _nameMap["VOLUME_UP"] = VOLUME_UP;
            _nameMap["W"] = W;
            _nameMap["X"] = X;
            _nameMap["Y"] = Y;
            _nameMap["Z"] = Z;
            _nameMap["ZOOM"] = ZOOM;

            _nameMap["BUTTON_A"] = BUTTON_A;
            _nameMap["BUTTON_B"] = BUTTON_B;
            _nameMap["BUTTON_BACK"] = BUTTON_BACK;
            _nameMap["BUTTON_BIG"] = BUTTON_BIG;
            _nameMap["BUTTON_DPAD_DOWN"] = BUTTON_DPAD_DOWN;
            _nameMap["BUTTON_DPAD_LEFT"] = BUTTON_DPAD_LEFT;
            _nameMap["BUTTON_DPAD_RIGHT"] = BUTTON_DPAD_RIGHT;
            _nameMap["BUTTON_DPAD_UP"] = BUTTON_DPAD_UP;
            _nameMap["BUTTON_LEFT_SHOULDER"] = BUTTON_LEFT_SHOULDER;
            _nameMap["BUTTON_LEFT_STICK"] = BUTTON_LEFT_STICK;
            _nameMap["BUTTON_LEFT_THUMB_DOWN"] = BUTTON_LEFT_THUMB_DOWN;
            _nameMap["BUTTON_LEFT_THUMB_LEFT"] = BUTTON_LEFT_THUMB_LEFT;
            _nameMap["BUTTON_LEFT_THUMB_RIGHT"] = BUTTON_LEFT_THUMB_RIGHT;
            _nameMap["BUTTON_LEFT_THUMB_UP"] = BUTTON_LEFT_THUMB_UP;
            _nameMap["BUTTON_LEFT_TRIGGER"] = BUTTON_LEFT_TRIGGER;
            _nameMap["BUTTON_RIGHT_SHOULDER"] = BUTTON_RIGHT_SHOULDER;
            _nameMap["BUTTON_RIGHT_STICK"] = BUTTON_RIGHT_STICK;
            _nameMap["BUTTON_RIGHT_THUMB_DOWN"] = BUTTON_RIGHT_THUMB_DOWN;
            _nameMap["BUTTON_RIGHT_THUMB_LEFT"] = BUTTON_RIGHT_THUMB_LEFT;
            _nameMap["BUTTON_RIGHT_THUMB_RIGHT"] = BUTTON_RIGHT_THUMB_RIGHT;
            _nameMap["BUTTON_RIGHT_THUMB_UP"] = BUTTON_RIGHT_THUMB_UP;
            _nameMap["BUTTON_RIGHT_TRIGGER"] = BUTTON_RIGHT_TRIGGER;
            _nameMap["BUTTON_START"] = BUTTON_START;
            _nameMap["BUTTON_X"] = BUTTON_X;
            _nameMap["BUTTON_Y"] = BUTTON_Y;

            _nameMap["MOUSE_BUTTON1"] = MOUSE_BUTTON1;
            _nameMap["MOUSE_BUTTON2"] = MOUSE_BUTTON2;
            _nameMap["MOUSE_BUTTON3"] = MOUSE_BUTTON3;
            _nameMap["MOUSE_BUTTON4"] = MOUSE_BUTTON4;
            _nameMap["MOUSE_BUTTON5"] = MOUSE_BUTTON5;
            _nameMap["MOUSE_X"] = MOUSE_X;
            _nameMap["MOUSE_X_DELTA"] = MOUSE_X_DELTA;
            _nameMap["MOUSE_Y"] = MOUSE_Y;
            _nameMap["MOUSE_Y_DELTA"] = MOUSE_Y_DELTA;
            _nameMap["MOUSE_WHEEL"] = MOUSE_WHEEL;
            _nameMap["MOUSE_WHEEL_DELTA"] = MOUSE_WHEEL_DELTA;

            _nameMap["THUMBSTICK_LEFT_X"] = THUMBSTICK_LEFT_X;
            _nameMap["THUMBSTICK_LEFT_X_DELTA"] = THUMBSTICK_LEFT_X_DELTA;
            _nameMap["THUMBSTICK_LEFT_Y"] = THUMBSTICK_LEFT_Y;
            _nameMap["THUMBSTICK_LEFT_Y_DELTA"] = THUMBSTICK_LEFT_Y_DELTA;
            _nameMap["THUMBSTICK_RIGHT_X"] = THUMBSTICK_RIGHT_X;
            _nameMap["THUMBSTICK_RIGHT_X_DELTA"] = THUMBSTICK_RIGHT_X_DELTA;
            _nameMap["THUMBSTICK_RIGHT_Y"] = THUMBSTICK_RIGHT_Y;
            _nameMap["THUMBSTICK_RIGHT_Y_DELTA"] = THUMBSTICK_RIGHT_Y_DELTA;

            _nameMap["TRIGGER_LEFT"] = TRIGGER_LEFT;
            _nameMap["TRIGGER_LEFT_DELTA"] = TRIGGER_LEFT_DELTA;
            _nameMap["TRIGGER_RIGHT"] = TRIGGER_RIGHT;
            _nameMap["TRIGGER_RIGHT_DELTA"] = TRIGGER_RIGHT_DELTA;
        }
    }
}
